<?php  
	/** 
	 * 入口Controller 后台首页类
	 * @author wxy last update on 2016-1-20
	 * 
	 */  
	class indexController extends adminController {
		var $pageNum;

		public function __construct(){
			parent::__construct();
			$this->adminService = InitPHP::getService("admin"); 			//实例化service层
		}

		//Action白名单,用于可以再外部用url访问，形式为参数a的值
		public $initphp_list = array("index",'setpwd','left','leftset');  

	    /**
	     * 自定义方法1 get_gp("uid");
	     * by wxy
	     */
	    function index(){
	    	$navTitle = '首页';
    		$list[] = array("url"=>$this->_jump . "c=index&a=setpwd","title"=>"修改密码");
			$list[] = array("url"=>"","title"=>"公共部分",
							  "content"=>array(
							  		array("url"=>$this->_jump . "c=example&a=example_list","title"=>"列表"),
							  		array("url"=>"admin.php?c=example&a=example_add","title"=>"添加"),
							  		array("url"=>"admin.php?c=example&a=example_add&type=dialog","title"=>"弹窗列表"),
							  		array("url"=>"admin.php?c=example&a=example_list","title"=>"添加3"),
							  		array("url"=>"admin.php?c=example&a=example_list","title"=>"查看"),
							  )
						);
			$this->view->assign('list', $list);
			$this->view->assign('navTitle', $navTitle);

	    	//魔板显示 view api
	    	$this->view->display("index_menu"); //调用hello.htm模板，后缀名.htm不需要填写  
	    } 

	    /**
	     * 修改密码
	     * @return 
	     * @author wxy 
	     */
	    function setpwd(){

	    	$action = $this->controller->get_gp("action");

	    	//验证原密码是否正确
	    	if($action == 'checkold'){
	    		$arr = array('pwd' => md5($_GET['oldpwd']), 'id' => $this->admin_id);
	    		$info = $this->adminService->getAdminOne($arr);
	    		if(!$info['id']){
					$res="原密码错误";
					echo json_encode($res);
				}else{
					$res='true';
					echo $res;
				}
				exit();	
	    	}

	    	if($_POST){
	    		$pwd = $this->controller->get_gp("pwd");
				$arr = array('pwd' => md5($pwd));
				$field = array('id' => $this->admin_id);
				$res = $this->adminService->adminUpdate($arr, $field);
				$statusCode = '300';
				$msg = '修改失败';
				if($res){
					$msg = '修改成功';
					$statusCode = '200';
				}
	    		die($this->ajaxDone($msg, $statusCode));
	    	}
	    	
	    	$this->view->display("setpwd");  
	    } 

	    /**
	     * 首页 点击获取
	     * @return  
	     */
	    function left(){
	    	$navTitle = '首页';
    		$list[] = array("url"=>$this->_jump . "c=index&a=setpwd","title"=>"修改密码");
			$list[] = array("url"=>"","title"=>"公共部分",
							  "content"=>array(
							  		array("url"=>"admin.php?c=example&a=example_list","title"=>"列表"),
							  		array("url"=>"admin.php?c=example&a=example_add","title"=>"添加"),
							  		array("url"=>"admin.php?c=example&a=example_add2","title"=>"添加2"),
							  		array("url"=>"admin.php?c=example&a=example_add3","title"=>"添加3"),
							  		array("url"=>"admin.php?c=example&a=example_veiw","title"=>"查看"),
							  )
						);
			$this->view->assign('list', $list);
			$this->view->assign('navTitle', $navTitle);
			$this->view->display("left"); 
	    } 


	    private function left_index(){
	    	$navTitle = '首页';
    		$list[] = array("url"=>$this->_jump . "c=index&a=setpwd","title"=>"修改密码");
			$list[] = array("url"=>"","title"=>"公共部分",
							  "content"=>array(
							  		array("url"=>"admin.php?c=example&a=example_list","title"=>"列表"),
							  		array("url"=>"admin.php?c=example&a=example_add","title"=>"添加"),
							  		array("url"=>"admin.php?c=example&a=example_add2","title"=>"添加2"),
							  		array("url"=>"admin.php?c=example&a=example_add3","title"=>"添加3"),
							  		array("url"=>"admin.php?c=example&a=example_veiw","title"=>"查看"),
							  )
						);
			$this->view->assign('list', $list);
			$this->view->assign('navTitle', $navTitle);
	    }

	    /**
	     * 网站设置
	     * @return  
	     */
	    function leftset(){
	    	$navTitle = '设置';
    		$list[] = array("url"=>$this->_jump . "c=index&a=setpwd","title"=>"网站信息");
    		$list[] = array("url"=>$this->_jump . "c=index&a=setpwd","title"=>"企业邮箱");
			$this->view->assign('list', $list);
			$this->view->assign('navTitle', $navTitle);

			$this->view->display("left"); 
	    } 

	}  
?>